package com.team.abs.service;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

@Service
public class kmeansServiceImp implements kmeansServer{

	@Override
	public List<String> dokmeans(int type, String PATHFILE) {
		String a=String.valueOf(type);
		String b=PATHFILE+"_jieba.txt";
		//System.out.println(a+"/n"+b);
		ArrayList<String>list=new ArrayList();
		try {
			String[]args=new String[]{ "python", "D:\\pythonplace\\spider\\weibo\\k_value.py", a, b };
			   Process proc = Runtime.getRuntime().exec(args);// 执行py文件
				 
			    BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
			    String line = null;
			   
			    while ((line = in.readLine()) != null) {
			       list.add(line);
			       //System.out.println(line);
			    }
			    in.close();
			    proc.waitFor();
			} catch (IOException e) {
			    e.printStackTrace();
			} catch (InterruptedException e) {
			    e.printStackTrace();
			}
				return list;
		
	}

}
